# This exists only to pass definitions to moc.
# - The default QT4_AUTOMOC does not include -D options and causes failure
#   if conditional compilation affects QT-related macros. (Oct 2007)
#   (Otherwise this should remain a copy of the usual routine.)

MACRO(QT4_MANUALMOC outfiles)
    QT4_GET_MOC_INC_DIRS(moc_includes)
    GET_DIRECTORY_PROPERTY(moc_definitions DEFINITIONS)
    # Grab the -D options
    STRING(REGEX MATCHALL "-D[^- ]*" moc_definitions "${moc_definitions}")

    FOREACH (it ${ARGN})
        GET_FILENAME_COMPONENT(it ${it} ABSOLUTE)
        GET_FILENAME_COMPONENT(outfile ${it} NAME_WE)
        SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.moc)

        ADD_CUSTOM_COMMAND(OUTPUT ${outfile}
            COMMAND ${QT_MOC_EXECUTABLE}
            ARGS ${moc_definitions} ${moc_includes} ${it} -o ${outfile}
            DEPENDS ${it})
        LIST(APPEND ${outfiles} ${outfile})
    ENDFOREACH(it)
ENDMACRO(QT4_MANUALMOC)
